package QC.MessageBox.beans.wxmsg.passivemsg;

import QC.MessageBox.beans.wxmsg.BaseWXMsg;

/**
 * Created by Andaren on 2017/5/13.
 * Used for:
 */
public class WXTextReply extends BaseWXMsg {

    private String content;

    // 微信文本消息格式化
    private static StringBuffer textXmlBuffer = new StringBuffer()
            .append("<xml>")
            .append("<ToUserName><![CDATA[%1$s]]></ToUserName>")
            .append("<FromUserName><![CDATA[%2$s]]></FromUserName>")
            .append("<CreateTime>%3$s</CreateTime>")
            .append("<MsgType><![CDATA[text]]></MsgType>")
            .append("<Content><![CDATA[%4$s]]></Content>")
            .append("<MsgId>%5$s")
            .append("</MsgId>")
            .append("</xml>");

    public WXTextReply() {}

    public String getContent() {
        return content;
    }

    public WXTextReply setContent(String content) {
        this.content = content;
        return this;
    }

    /**
     * 构造被动回复文本消息
     * @return
     */
    public String buildXml() {
        return String.format(textXmlBuffer.toString(),
                getToUserName(),
                getFromUserName(),
                getCreateTime(),
                content,
                getMsgId());
    }

}
